import { LocaleProvider } from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
import 'moment/locale/zh-cn';
import React from 'react';
import ReactDOM from 'react-dom';
import {Router,Route,browserHistory,IndexRoute} from 'react-router';
import App from './App'; //根目录文件 路由父组件 包含上导航，左菜单
// import App from './myApp'; //根目录文件 路由父组件 包含上导航，左菜单
import Home from './components/home';
import registerServiceWorker from './registerServiceWorker';//缓存服务文件 开启本地的一个server worker 放最后
//引入路由组件
// import RegisterTriage from './components/medical/registerTriage/registerTriage'; //专家门诊组件
// import InquiryCenter from './components/medical/inquiryCenter/inquiryCenter'; //专家门诊
//工作台下二级目录
import ProductManage from './components/homePage/productManage/productManage';//商品管理
import OrderManage from './components/homePage/orderManage/orderManage';//订单管理
import ScheduleManage from './components/homePage/scheduleManage/scheduleManage';//排班管理
import DepartmentsManage from './components/homePage/departmentsManage/departmentsManage';//科室管理
import GoodsManage from './components/homePage/goodsManage/goodsManage';//药品/物资库管理
import StatisticsStatements from './components/homePage/statisticsStatements/statisticsStatements';//统计报表
import DeliveryManage from './components/homePage/deliveryManage/deliveryManage';//配送管理
//门店管理下三级目录
import StoreManage from './components/homePage/storeManage/storeManage/storeManage';//门店管理
import RoleManage from './components/homePage/storeManage/roleManage/roleManage';//角色组管理
import EmployeeManage from './components/homePage/storeManage/employeeManage/employeeManage';//员工管理
import RegistrationFeeManage from './components/homePage/storeManage/registrationFeeManage/registrationFeeManage';//医生挂号费管理
import ScheduleSetting from './components/homePage/storeManage/scheduleSetting/scheduleSetting';//排班设置
import CaseTemplate from './components/homePage/storeManage/caseTemplate/caseTemplate';//病例模板管理
import PrescriptionTemplate from './components/homePage/storeManage/prescriptionTemplate/prescriptionTemplate';//处方模板
import AssistantTherapyTemplate from './components/homePage/storeManage/assistantTherapyTemplate/assistantTherapyTemplate';//辅助治疗模板
import UserTypeManage from './components/homePage/storeManage/userTypeManage/userTypeManage';//会员类型折扣管理
import PatientOriginManage from './components/homePage/storeManage/patientOriginManage/patientOriginManage';//患者来源管理
//医疗下二级目录
import RegisterTriage from './components/medicalDepartment/registerTriage/registerTriage';//登记并分诊
import Triage from './components/medicalDepartment/triage/triage'//分诊
import DoctorSection from './components/medicalDepartment/doctorSection/doctorSection';//医生门诊
import AssistantTherapy from './components/medicalDepartment/assistantTherapy/assistantTherapy';//辅助治疗
import Pharmacy from './components/medicalDepartment/pharmacy/pharmacy';//药房
import Cash from './components/medicalDepartment/cash/cash';//收银
import AppointmentOnline from './components/medicalDepartment/appointmentOnline/appointmentOnline';//网上预约
import InquiryCenter from './components/medicalDepartment/inquiryCenter/inquiryCenter';//问诊中心
import Goods from './components/medicalDepartment/goods/goods';//药品/物资库
import UserManage from './components/medicalDepartment/userManage/userManage';//会员管理
import OperationLog from './components/medicalDepartment/operationLog/operationLog';//操作日志
import AddStoreForm from './components/homePage/storeManage/storeManage/addStore';//新增门店
import AddFirstDepartmentForm from './components/homePage/departmentsManage/addFirstDepartment';//新增一级科室
import AddRegistrationFeeForm from './components/homePage/storeManage/registrationFeeManage/addRegistrationFee';//新增医生挂号费
import RolePrivilegeForm from './components/homePage/storeManage/roleManage/changeRolePrivilege';//权限设置
import AddEmployeeForm from './components/homePage/storeManage/employeeManage/addEmployee';//增加新员工
import AddSchedule from './components/homePage/storeManage/scheduleSetting/addSchedule';//增加排班
import AddCaseTemplateForm from './components/homePage/storeManage/caseTemplate/addCaseTemplate';//增加病例模板
import AddPrescriptionTemplateForm from './components/homePage/storeManage/prescriptionTemplate/addPrescriptionTemplate';//增加处方模板
import AddAssistantTherapyTemplateForm from './components/homePage/storeManage/assistantTherapyTemplate/addAssistantTherapyTemplate';//增加辅助模板
import AddUserTypeForm from './components/homePage/storeManage/userTypeManage/addUserType';//增加会员类型
import AddPatientOriginForm from './components/homePage/storeManage/patientOriginManage/addPatientOrigin';//增加患者来源
import UpdatePassword from './components/aboutAdminCount/updatePassword';//更改用户密码
import PayConfirm from './components/medicalDepartment/registerTriage/payConfirm';//订单确认页面
import PatientInfoDetails from './components/medicalDepartment/registerTriage/patientInfoDetails';//患者详细信息
import TreatPatientsForm from './components/medicalDepartment/doctorSection/treatPatients';//医生接诊
import GetMedicine from './components/medicalDepartment/pharmacy/getMedicine';//药房取药详情
import AssistantTherapyDetails from './components/medicalDepartment/assistantTherapy/assiatantTherapyDetails';//药房取药详情
//登录路由
import Login from './Login';//登录模块

const userInfo = JSON.parse(sessionStorage.getItem('UserInfo')); //用户信息
// const userInfo = sessionStorage.getItem('UserInfo'); //用户信息
// const keyword = sessionStorage.getItem('keyword'); //权限关键字
const token = sessionStorage.getItem('token');//token
if(!userInfo && !token){
    browserHistory.push('login');
    // window.location.href = './login';
}
class Index extends React.Component {
    render() {
        return (
            <Router history={browserHistory}>
                <Route path='/login' component={Login}/>
                <Route path='/' component={App} >
                    <IndexRoute component={Home} />
                    <Route path='register_triage' component={RegisterTriage}/>
                    <Route path='inquiry_center' component={InquiryCenter}/>
                    <Route path='productManage' component={ProductManage}/>
                    <Route path='orderManage' component={OrderManage}/>
                    <Route path='scheduleManage' component={ScheduleManage}/>
                    <Route path='departmentsManage' component={DepartmentsManage}/>
                    <Route path='goodsManage' component={GoodsManage}/>
                    <Route path='statisticsStatements' component={StatisticsStatements}/>
                    <Route path='deliveryManage' component={DeliveryManage}/>
                    <Route path='storeManage' component={StoreManage}/>
                    <Route path='roleManage' component={RoleManage}/>
                    <Route path='employeeManage' component={EmployeeManage}/>
                    <Route path='registrationFeeManage' component={RegistrationFeeManage}/>
                    <Route path='scheduleSetting' component={ScheduleSetting}/>
                    <Route path='caseTemplate' component={CaseTemplate}/>
                    <Route path='prescriptionTemplate' component={PrescriptionTemplate}/>
                    <Route path='assistantTherapyTemplate' component={AssistantTherapyTemplate}/>
                    <Route path='userTypeManage' component={UserTypeManage}/>
                    <Route path='patientOriginManage' component={PatientOriginManage}/>
                    <Route path='registerTriage' component={RegisterTriage}/>
                    <Route path='triage' component={Triage}/>
                    <Route path='doctorSection' component={DoctorSection}/>
                    <Route path='assistantTherapy' component={AssistantTherapy}/>
                    <Route path='pharmacy' component={Pharmacy}/>
                    <Route path='cash' component={Cash}/>
                    <Route path='appointmentOnline' component={AppointmentOnline}/>
                    <Route path='inquiryCenter' component={InquiryCenter}/>
                    <Route path='goods' component={Goods}/>
                    <Route path='userManage' component={UserManage}/>
                    <Route path='operationLog' component={OperationLog}/>
                    <Route path='addStoreForm/:storeId' component={AddStoreForm}/>
                    <Route path='addFirstDepartmentForm/:departmentId/:isEdit' component={AddFirstDepartmentForm}/>
                    <Route path='addRegistrationFeeForm/:feeId' component={AddRegistrationFeeForm}/>
                    <Route path='rolePrivilegeForm/:roleId/:roleName' component={RolePrivilegeForm}/>
                    <Route path='addEmployeeForm/:employeeId' component={AddEmployeeForm}/>
                    <Route path='addSchedule/:scheduleId' component={AddSchedule}/>
                    <Route path='addCaseTemplateForm' component={AddCaseTemplateForm}/>
                    <Route path='addPrescriptionTemplateForm' component={AddPrescriptionTemplateForm}/>
                    <Route path='addAssistantTherapyTemplateForm' component={AddAssistantTherapyTemplateForm}/>
                    <Route path='addUserTypeForm/:userTypeId' component={AddUserTypeForm}/>
                    <Route path='addPatientOriginForm/:patientOriginId' component={AddPatientOriginForm}/>
                    <Route path='updatePassword' component={UpdatePassword}/>
                    <Route path='payConfirm' component={PayConfirm}/>
                    <Route path='patientInfoDetails/:patientId' component={PatientInfoDetails}/>
                    <Route path='treatPatientsForm' component={TreatPatientsForm}/>
                    <Route path='getMedicine' component={GetMedicine}/>
                    <Route path='assistantTherapyDetails/:patientId' component={AssistantTherapyDetails}/>
                </Route>
            </Router>
        );
    }
}
ReactDOM.render(<LocaleProvider locale={zh_CN}><Index /></LocaleProvider>, document.getElementById('root'));
registerServiceWorker();
